{extend name="../../admin/view/main"}

{block name='content'}
<div class="think-box-shadow">
    <form action="{:request()->url()}" autocomplete="off" class="layui-form layui-card" data-auto="true" method="post">
        <div class="layui-card-body padding-left-40 padding-top-30" style="width:1200px">

            <!-- 结算方式 开始 -->
            <div class="layui-form-item">
                <div class="layui-row layui-col-space20">
                    <div class="layui-col-xs6">
                        <fieldset class="block">
                            <legend><span class="layui-badge">结算到账</span></legend>
                            <div class="layui-form-item">
                                {php} $data['settl_type'] = $data['settl_type'] ?? 1; {/php}
                                {foreach [1 => '支付后立即到账', 2 => '确认收货后到账'] as $key => $val}{if $data.settl_type eq $key}
                                <input class="layui-input" name="settl_type" title="{$val}" type="radio" value="{$key}" checked>
                                {else}
                                <input class="layui-input" name="settl_type" title="{$val}" type="radio" value="{$key}">
                                {/if}{/foreach}
                            </div>
                        </fieldset>
                    </div>
                    <div class="layui-col-xs6">
                        <fieldset class="block">
                            <legend><span class="layui-badge">团队结算</span></legend>
                            <div class="layui-form-item">
                                {php} $data['teams_type'] = $data['teams_type'] ?? 1; {/php}
                                {foreach [1 => '实时结算'] as $key=>$val}{if $data.teams_type eq $key}
                                <input class="layui-input" name="teams_type" title="{$val}" type="radio" value="{$key}" checked>
                                {else}
                                <input class="layui-input" name="teams_type" title="{$val}" type="radio" value="{$key}">
                                {/if}{/foreach}
                            </div>
                        </fieldset>
                    </div>
                </div>
            </div>
            <!-- 结算方式 结束 -->

            <div class="layui-form-item">
                <fieldset class="block">
                    <legend><span class="layui-badge">平推奖励</span></legend>
                    <div class="layui-form-item">
                        <div class="layui-row layui-col-space20">
                            {foreach $levels as $level}
                            <div class="layui-col-xs6">
                                <fieldset class="block margin-0">
                                    <legend>
                                        {php} $key = 'equal_state_vip_'.$level['number']; {/php}
                                        <input name="{$key}" type="hidden" value="0">
                                        {php} $data[$key] = $data[$key] ?? 0; {/php}
                                        {if isset($data[$key]) and $data[$key] eq 1}
                                        <input checked lay-skin="switch" lay-text="已启用平推 {$level.name} 奖励|已停用平推 {$level.name} 奖励" name="{$key}" type="checkbox" value="1">
                                        {else}
                                        <input lay-skin="switch" lay-text="已启用平推 {$level.name} 奖励|已停用平推 {$level.name} 奖励" name="{$key}" type="checkbox" value="1">
                                        {/if}
                                    </legend>
                                    <div class="layui-form-item">
                                        <div class="layui-row layui-col-space20">
                                            <label class="layui-col-xs6">
                                                {php} $key = 'equal_value_vip_1_'.$level['number']; {/php}
                                                <span><b class="color-blue">请输入直属上级奖励金额</b><br>如：比例填写 10.00 表示 10.00 元</span>
                                                <input class="layui-input" data-blur-number="2" name="{$key}" placeholder="请输入奖励金额" type="text" value="{$data[$key]??'0.00'}">
                                            </label>
                                            <label class="layui-col-xs6">
                                                {php} $key = 'equal_value_vip_2_'.$level['number']; {/php}
                                                <span><b class="color-blue">请输入上上级奖励金额</b><br>如：比例填写 10.00 表示 10.00 元</span>
                                                <input class="layui-input" data-blur-number="2" name="{$key}" placeholder="请输入奖励金额" type="text" value="{$data[$key]??'0.00'}">
                                            </label>
                                        </div>
                                    </div>
                                </fieldset>
                            </div>
                            {/foreach}
                        </div>
                    </div>
                </fieldset>
            </div>

            <div class="layui-form-item">
                <div class="layui-tab layui-tab-card shadow-none">
                    <ul class="layui-tab-title">
                        {foreach $levels as $level}
                        <li data-rule-tab>[ <b class="color-red">VIP{$level.number|default=0}</b> ] {$level.name|default=''}</li>
                        {/foreach}
                    </ul>
                    <div class="layui-tab-content padding-0">
                        {foreach $levels as $level}
                        <div class="layui-tab-item">
                            <table class="layui-table margin-top-0 border-0" lay-skin="line">
                                <colgroup>
                                    <col style="width:150px">
                                </colgroup>
                                {foreach $levels as $l}
                                <tr class="think-bg-white">
                                    <th class="text-center font-w7 nowrap">
                                        {$level.name} <span class="layui-icon font-s10 color-desc">&#xe602;</span> {$l.name}
                                    </th>
                                    <td>
                                        <div class="layu-row layui-col-space20">
                                            <div class="layui-col-xs6">
                                                <fieldset class="block margin-0">
                                                    <legend>
                                                        {php} $key = 'frist_state_vip_'.$level['number'].'_'.$l['number']; {/php}
                                                        <input name="{$key}" type="hidden" value="0">
                                                        {php} $data[$key] = $data[$key] ?? 0; {/php}
                                                        {if isset($data[$key]) and $data[$key] eq 1}
                                                        <input lay-skin="switch" lay-text="已启用首推奖励|已停用首推奖励" name="{$key}" type="checkbox" value="1" checked>
                                                        {else}
                                                        <input lay-skin="switch" lay-text="已启用首推奖励|已停用首推奖励" name="{$key}" type="checkbox" value="1">
                                                        {/if}
                                                    </legend>
                                                    <div class="layui-form-item">
                                                        {php} $key = 'frist_type_vip_'.$level['number'].'_'.$l['number']; {/php}
                                                        <input name="{$key}" type="hidden" value="1">
                                                        {php} $data[$key] = $data[$key] ?? 1; {/php}
                                                        {foreach [1 => '奖励固定金额 / 每单',2 => '按订单参与的返利金额比例'] as $k => $v}
                                                        {if isset($data[$key]) and $data[$key] eq $k}
                                                        <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}" checked>
                                                        {else}
                                                        <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}">
                                                        {/if}{/foreach}
                                                        <label class="block relative">
                                                            {php} $key = 'frist_value_vip_'.$level['number'].'_'.$l['number']; {/php}
                                                            <span class="color-blue"><b>请输入奖励金额或返利金额比例</b>（ 如：比例填写 10.00 表示 10.00% 或 10.00 元 ）</span>
                                                            <input class="layui-input" data-blur-number="4" name="{$key}" placeholder="请输入奖励金额或返利金额比例" type="text" value="{$data[$key]??'0.00000'}">
                                                        </label>
                                                    </div>
                                                </fieldset>
                                            </div>
                                            <div class="layui-col-xs6">
                                                <fieldset class="block margin-0">
                                                    <legend>
                                                        {php} $key = 'repeat_state_vip_'.$level['number'].'_'.$l['number']; {/php}
                                                        <input name="{$key}" type="hidden" value="0">
                                                        {php} $data[$key] = $data[$key] ?? 0; {/php}
                                                        {if isset($data[$key]) and $data[$key] eq 1}
                                                        <input lay-skin="switch" lay-text="已启用复购奖励|已停用复购奖励" name="{$key}" type="checkbox" value="1" checked>
                                                        {else}
                                                        <input lay-skin="switch" lay-text="已启用复购奖励|已停用复购奖励" name="{$key}" type="checkbox" value="1">
                                                        {/if}
                                                    </legend>
                                                    <div class="layui-form-item">
                                                        {php} $key = 'repeat_type_vip_'.$level['number'].'_'.$l['number']; {/php}
                                                        {php} $data[$key] = $data[$key] ?? 1; {/php}
                                                        {foreach [1 => '奖励固定金额 / 每单', 2 => '按订单参与的返利金额比例'] as $k => $v}
                                                        {if isset($data[$key]) and $data[$key] eq $k}
                                                        <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}" checked>
                                                        {else}
                                                        <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}">
                                                        {/if}{/foreach}
                                                        <label class="block relative">
                                                            {php} $key = 'repeat_value_vip_'.$level['number'].'_'.$l['number']; {/php}
                                                            <span class="color-blue"><b>请输入奖励金额或返利金额比例</b>（ 如：比例填写 10.00 表示 10.00% 或 10.00 元 ）</span>
                                                            <input class="layui-input" data-blur-number="4" name="{$key}" placeholder="请输入奖励金额或返利金额比例" type="text" value="{$data[$key]??'0.0000'}">
                                                        </label>
                                                    </div>
                                                </fieldset>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                {/foreach}
                            </table>
                            <div class="padding-20">
                                <div class="layui-row layui-col-space20">
                                    <div class="layui-col-xs6">
                                        <fieldset class="block">
                                            <legend>
                                                {php} $key = 'direct_state_vip_'.$level['number']; {/php}
                                                <input name="{$key}" type="hidden" value="0">
                                                {php} $data[$key] = $data[$key] ?? 0; {/php}
                                                {if isset($data[$key]) and $data[$key] eq 1}
                                                <input lay-skin="switch" lay-text="已启用 {$level.name} 的直属团队奖励|已停用 {$level.name} 的直属团队奖励" name="{$key}" type="checkbox" value="1" checked>
                                                {else}
                                                <input lay-skin="switch" lay-text="已启用 {$level.name} 的直属团队奖励|已停用 {$level.name} 的直属团队奖励" name="{$key}" type="checkbox" value="1">
                                                {/if}
                                            </legend>
                                            <div class="layui-form-item">
                                                {php} $key = 'direct_type_vip_'.$level['number']; {/php}
                                                {php} $data[$key] = $data[$key] ?? 1; {/php}
                                                {foreach [1 => '奖励固定金额 / 每单',2 => '按订单参与的返利金额比例'] as $k => $v}
                                                {if isset($data[$key]) and $data[$key] eq $k}
                                                <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}" checked>
                                                {else}
                                                <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}">
                                                {/if}{/foreach}
                                                <label class="block nowrap">
                                                    {php} $key = 'direct_value_vip_'.$level['number']; {/php}
                                                    <span class="color-blue"><b>请输入奖励金额或返利金额比例</b>（ 如：比例填写 10.00 表示 10.00% 或 10.00 元 ）</span>
                                                    <input class="layui-input" data-blur-number="4" name="{$key}" placeholder="请输入奖励金额或返利金额比例" type="text" value="{$data[$key]??'0.0000'}">
                                                </label>
                                            </div>
                                        </fieldset>
                                    </div>
                                    <div class="layui-col-xs6">
                                        <fieldset class="block">
                                            <legend>
                                                {php} $key = 'indirect_state_vip_'.$level['number']; {/php}
                                                <input name="{$key}" type="hidden" value="0">
                                                {php} $data[$key] = $data[$key] ?? 0; {/php}
                                                {if isset($data[$key]) and $data[$key] eq 1}
                                                <input lay-skin="switch" lay-text="已启用 {$level.name} 的间接团队奖励|已停用 {$level.name} 的间接团队奖励" name="{$key}" type="checkbox" value="1" checked>
                                                {else}
                                                <input lay-skin="switch" lay-text="已启用 {$level.name} 的间接团队奖励|已停用 {$level.name} 的间接团队奖励" name="{$key}" type="checkbox" value="1">
                                                {/if}
                                            </legend>
                                            <div class="layui-form-item nowrap">
                                                {php} $key = 'indirect_type_vip_'.$level['number']; {/php}
                                                {php} $data[$key] = $data[$key] ?? 1; {/php}
                                                {foreach [1 => '奖励固定金额 / 每单',2 => '按订单参与的返利金额比例'] as $k => $v}
                                                {if isset($data[$key]) and $data[$key] eq $k}
                                                <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}" checked>
                                                {else}
                                                <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}">
                                                {/if}{/foreach}
                                                <label class="block">
                                                    {php} $key = 'indirect_value_vip_'.$level['number']; {/php}
                                                    <span class="color-blue"><b>请输入奖励金额或返利金额比例</b>（ 如：比例填写 10.00 表示 10.00% 或 10.00 元 ）</span>
                                                    <input class="layui-input" data-blur-number="4" name="{$key}" placeholder="请输入奖励金额或返利金额比例" type="text" value="{$data[$key]??'0.0000'}">
                                                </label>
                                            </div>
                                        </fieldset>
                                    </div>
                                </div>
                                <div class="layui-row layui-col-space20">
                                    <div class="layui-col-xs6">
                                        <fieldset class="block">
                                            <legend>
                                                {php} $key = 'upgrade_state_vip_'.$level['number']; {/php}
                                                <input name="{$key}" type="hidden" value="0">
                                                {php} $data[$key] = $data[$key] ?? 0; {/php}
                                                {if isset($data[$key]) and $data[$key] eq 1}
                                                <input checked lay-skin="switch" lay-text="已启用用户升级 {$level.name} 奖励|已停用用户升级 {$level.name} 奖励" name="{$key}" type="checkbox" value="1">
                                                {else}
                                                <input lay-skin="switch" lay-text="已启用用户升级 {$level.name} 奖励|已停用用户升级 {$level.name} 奖励" name="{$key}" type="checkbox" value="1">
                                                {/if}
                                            </legend>
                                            <div class="layui-form-item nowrap">
                                                {php} $key = 'upgrade_type_vip_'.$level['number'].'_'.$l['number']; {/php}
                                                <input name="{$key}" type="hidden" value="1">
                                                {php} $data[$key] = $data[$key] ?? 1; {/php}
                                                {foreach [1 => '奖励固定金额 / 每单',2 => '按订单参与的返利金额比例'] as $k => $v}
                                                {if isset($data[$key]) and $data[$key] eq $k}
                                                <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}" checked>
                                                {else}
                                                <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}">
                                                {/if}{/foreach}
                                                <label class="block">
                                                    {php} $key = 'upgrade_value_vip_'.$level['number']; {/php}
                                                    <span class="color-blue"><b>请输入固定奖励金额</b>（ 如：比例填写 10.00 表示 10.00 元或 10.00% ）<b class="color-red">仅针对订单升级有效！</b></span>
                                                    <input class="layui-input" data-blur-number="4" name="{$key}" placeholder="请输入奖励金额或返利金额比例" type="text" value="{$data[$key]??'0.0000'}">
                                                </label>
                                            </div>
                                        </fieldset>
                                    </div>
                                    <div class="layui-col-xs6">
                                        <fieldset class="block">
                                            <legend>
                                                {php} $key = 'manage_state_vip_'.$level['number']; {/php}
                                                <input name="{$key}" type="hidden" value="0">
                                                {php} $data[$key] = $data[$key] ?? 0; {/php}
                                                {if isset($data[$key]) and $data[$key] eq 1}
                                                <input checked lay-skin="switch" lay-text="已启用用户 {$level.name} 管理奖励|已停用用户 {$level.name} 管理奖励" name="{$key}" type="checkbox" value="1">
                                                {else}
                                                <input lay-skin="switch" lay-text="已启用用户 {$level.name} 管理奖励|已停用用户 {$level.name} 管理奖励" name="{$key}" type="checkbox" value="1">
                                                {/if}
                                            </legend>
                                            <div class="layui-form-item nowrap">
                                                {php} $key = 'manage_type_vip_'.$level['number']; {/php}
                                                {php} $data[$key] = $data[$key] ?? 1; {/php}
                                                {foreach [1 => '不累计未发管理奖金额', 2 => '累计未发放管理奖金'] as $k => $v}
                                                {if isset($data[$key]) and $data[$key] eq $k}
                                                <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}" checked>
                                                {else}
                                                <input class="layui-input" name="{$key}" title="{$v}" type="radio" value="{$k}">
                                                {/if}{/foreach}
                                                <label class="block">
                                                    {php} $key = 'manage_value_vip_'.$level['number']; {/php}
                                                    <span class="color-blue"><b>请输入固定奖励金额</b>（ 如：比例填写 10.00 表示 10.00 元 ）</span>
                                                    <input class="layui-input" data-blur-number="4" name="{$key}" placeholder="请输入奖励金额或返利金额比例" type="text" value="{$data[$key]??'0.0000'}">
                                                </label>
                                            </div>
                                        </fieldset>
                                    </div>
                                </div>
                            </div>
                        </div>
                        {/foreach}
                    </div>
                </div>
            </div>

            <div class="layui-form-item text-center margin-top-30">
                <button class="layui-btn" type='submit'>保存配置</button>
                <button class="layui-btn layui-btn-danger" data-confirm="确定要取消编辑吗？" data-history-back type='button'>取消编辑</button>
            </div>

        </div>
    </form>

    <script>
        $(function () {
            layui.form.render(), layui.element.render();
            $('li[data-rule-tab]:first-child').trigger('click');
        });
    </script>
</div>
{/block}